<template>
	<view class="my-goods-container">
		<view class="left">
			<radio :checked="goods.goods_state" color="#C00000" v-if="showRadio" @click="radioChange"></radio>
			<image :src="goods.goods_small_logo"></image>
		</view>
		<view class="right">
			<text class="goodsName">{{goods.goods_name}}</text>
			<view class="bottom">
				<text class="goodsPrice">￥{{goods.goods_price.toFixed(2)}}</text>
				<uni-number-box :inputValue="goods.goods_count" :min="1" @change="bindChange"></uni-number-box>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			goods: {
				type: Object,
				default: {}
			},
			showRadio: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			radioChange() {
				this.$emit('radio-change', {
					// 商品的 Id
					goods_id: this.goods.goods_id,
					// 商品最新的勾选状态
					goods_state: !this.goods.goods_state
				})
			},
			bindChange(val) {
				this.$emit('numChange', {
					// 商品的 Id
					goods_id: this.goods.goods_id,
					// 商品最新的数量
					goods_count: +val
				})
			}
		}
	}
</script>

<style lang="scss">
.my-goods-container {
	// 让 goods-item 项占满整个屏幕的宽度
	width: 750rpx;
	// 设置盒模型为 border-box
	box-sizing: border-box;
	display: flex;
	justify-content: space-between;
	.left {
		margin: 5px;
		display: flex;
		align-items: center;
		image {
			width: 100px;
			height: 100px;
		}
	}
	.right {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		.goodsName {
			margin-top: 10px;
			font-size: 13px;
		}
		.bottom {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 10px;
			.goodsPrice {
				color: #C00000;
			}
		}
		
	}
}
</style>
